package com.example.demo.untils;

import net.coobird.thumbnailator.Thumbnails;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.image.BufferedImage;
import java.io.File;

/**
 * @author ljh
 * @create 2019/8/6
 * @describe
 */
public class ImageUtil {
    public static void main(String[] args) throws Exception{
        BufferedImage bufferedImage = ImageIO.read(new File("d:/desert.jpg"));
        int iconWidth = bufferedImage.getWidth();
        int iconHeight = bufferedImage.getHeight();
        System.out.println(iconWidth + "," + iconHeight);
        Thumbnails.of("d:/desert.jpg")
                .scale(0.3f)
                .outputQuality(0.5f)
                .toFile("d:/desert_thum.jpg");
    }
}
